<script>
	function check($obj,$i,$x){
		var checked=$obj.checked;
		if(checked){
			$('.check-'+$i+'-'+$x).prop("checked",true);
		}else{
			$('.check-'+$i+'-'+$x).prop("checked",false);
		}
		parent($i,$x);
	}

	function checkChild($i,$x){
		var checkedLength=$('.check-'+$i+'-'+$x+':checked').length;
		if(checkedLength>0){
			$("#check-"+$i+'-'+$x).prop("checked",true);
		}else{
			$("#check-"+$i+'-'+$x).prop("checked",false);
		}
		parent($i,$x);
	}
	function parent($m,$n){
		var str='check-'+$m;
		var checkedLength=$("input[class^='"+str+"']:checked").length;
		if(checkedLength>0){
			$("#home"+$m).prop("checked",true);
		}else{
			$("#home"+$m).prop("checked",false);
		}
	}

	function home($obj,$y){
		var checked=$obj.checked;
		var str='check-'+$y;
		if(checked){
			$("input[class^='"+str+"']").prop("checked",true);
		}else{
			$("input[class^='"+str+"']").prop("checked",false);
		}
	}
</script>
<div class="page">
	<div class="pageContent">
	<form method="post" action="{:U(MODULE_NAME.'/'.CONTROLLER_NAME.'/rules','','')}/callbackType/closeCurrent/navTabId/groupList" class="pageForm required-validate" onsubmit="return validateCallback(this, dialogAjaxDone)">
	<div  layoutH="40">
	<input type="hidden" name="id" value="{$Think.get.id}">
<foreach name="note" item="v" key="k">
	<h2 class="contentTitle">{$v['title']} <input type="checkbox" name="rule_id[]" value="{$v['id']}" <in name="v['id']" value="$rules">checked='true'</in> group="rule_id[]" id="home{$k}" onclick="home(this,{$k})" /></h2>
	<div class="pageFormContent lxzdl">
		<foreach name="v['child']" item="vv" key="kk">
			<fieldset>
				<legend>{$vv['title']} <input type="checkbox" name="rule_id[]" value="{$vv['id']}" <in name="vv['id']"  value="$rules">checked='true'</in> onclick="check(this,{$k},{$kk})" id="check-{$k}-{$kk}" class="check-{$k}"/></legend>
					<foreach name="vv['child']" item="vvv">
						<label>{$vvv['title']} <input type="checkbox" name="rule_id[]" value="{$vvv['id']}" <in name="vvv['id']" value="$rules">checked='true'</in> class="check-{$k}-{$kk}" onclick="checkChild({$k},{$kk})"/></label>
					</foreach>
			</fieldset>
		</foreach>
	</div>
</foreach>
</div>
	<div class="formBar">
		<label style="float:left"><input type="checkbox" class="checkboxCtrl" group="rule_id[]" />全选</label>
		<ul>
			<!--<li><div class="button"><div class="buttonContent"><button type="button" class="checkboxCtrl" group="rule_id[]" selectType="invert">反选</button></div></div></li>-->
			<li><div class="buttonActive"><div class="buttonContent"><button type="submit">提交</button></div></div></li>
		</ul>
	</div>
</form>	
	</div>
</div>

